﻿using Daemon.Model;
using Daemon.Reflection;
using Daemon.Service.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Daemon.Data.Substructure.Framework;
using Microsoft.EntityFrameworkCore;
using Daemon.Middleware;
using Daemon.Data.Infrastructure.Configuration;

namespace Daemon.Service
{
    public class StudentScoreGridService : BaseGridService<StudentScoreGrid>, IStudentScoreGridService
    {
        protected override string SQLQuery => "select " + PrimaryKeyName + " from qryGridStudentScore";

        protected override Expression<Func<StudentScoreGrid, int>> GetId => c => c.Id;

        protected override string PrimaryKeyName => "Id";

        public StudentScoreGridService(ApiDBContent context, IDelimitedListParser delimitedListParser) : base(context, delimitedListParser)
        {

        }

        protected override IQueryable<StudentScoreGrid> CreateQueryable(ApiDBContent context, FilterSet filterSet)
        {
            var contextProvider = ServiceLocator.Resolve<IContextInfoProvider>();
            return context.Set<StudentScoreGrid>().AsNoTracking().Where(r => r.AddUserId == contextProvider.AuthInfo.UserId);
        }
    }
}
